using ASP;
using System;
using System.Runtime.CompilerServices;
using System.Web.Profile;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Buttons : System.Web.UI.UserControl
{
    public event EventHandler Click;

    public void btnCancel_Click(object sender, EventArgs e)
    {
        this.setButtons(string.Empty);
        this.OnClick(e);
    }

    public void btnDelete_Click(object sender, EventArgs e)
    {
        this.setButtons(string.Empty);
        this.OnClick(e);
    }

    public void btnModify_Click(object sender, EventArgs e)
    {
        this.setButtons("modify");
        this.OnClick(e);
    }

    public void btnNew_Click(object sender, EventArgs e)
    {
        this.setButtons("new");
        this.OnClick(e);
    }

    public void btnSave_Click(object sender, EventArgs e)
    {
        this.setButtons(string.Empty);
        this.OnClick(e);
    }

    protected virtual void OnClick(EventArgs e)
    {
        if (this.Click != null)
        {
            this.Click(this, e);
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        this.setButtons(string.Empty);
    }

    public void setButtons(string action)
    {
        switch (action)
        {
            case "new":
                this.btnNew.Enabled = false;
                this.btnModify.Enabled = false;
                this.btnSave.Enabled = true;
                this.btnDelete.Enabled = false;
                return;

            case "modify":
                this.btnNew.Enabled = false;
                this.btnModify.Enabled = false;
                this.btnSave.Enabled = true;
                this.btnDelete.Enabled = false;
                return;
        }
        this.btnNew.Enabled = true;
        this.btnModify.Enabled = true;
        this.btnSave.Enabled = false;
        this.btnDelete.Enabled = true;
    }
}
